package ls.jpa.chapter7.repository;

import ls.jpa.chapter7.entity.Person;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Barudisshu
 */
@Repository
public interface PersonRepository extends MongoRepository<Person, Integer> {


    Person findByName(String name);

    List<Person> findAll();

    /**
     * 本地化查询语句，参数名对应数组下标
     * @param sex 性别
     * @return Person
     */
    @Query(value = "{'sex':?0}")
    List<Person> findBySex(boolean sex);

    @Override
    <S extends Person> S save(S entity);
}
